#! /usr/bin/env perl

use strict;
use warnings;

use VCtools::Base;
use VCtools::Args;
use VCtools::Common;


#################################
# OPTIONS AND ENVIRONMENT VARS
#################################

VCtools::args('files', 'list', 'file(s) (or directory/ies) to revert back to repository status');
VCtools::getopts();

# remember, directories are files too
my @files = VCtools::files();


#################################
# CHECK FOR ERRORS
#################################

my $proj = VCtools::verify_files_and_group(@files);

=not_working_with_subversion_yet
my @lockers = cvs::getLockers($cvsroot, $module);
my $username = $::ENV{USER};
$username = $::ENV{USERNAME} if !$username;
if (!grep {$_ eq $username} @lockers)
{
	print "$me: you didn't do a get on this module\n";
	exit 1;
}
=cut

foreach my $file (@files)
{
	if (VCtools::get_diffs($file))
	{
		VCtools::info_msg("file $file contains modifications!");
		VCtools::info_msg("these changes will be lost forever!");
		exit unless VCtools::yesno("Are you sure you want to do this?");
	}
}


#################################
# MAIN
#################################

VCtools::revert_files(@files);
VCtools::reset_timestamp($_) foreach @files;

print "done\n" unless $?;
